Repository navigation
Conversation
|
I’m a little hesitant to add three more CLI options, since they will be difficult to remove once released. More broadly, a configuration file might be a better fit for describing sources and their dependencies. It could also leave room to associate source paths with module names, which may help with qualified lookup in the future. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep --dependency-sourcedirs as the only CLI input for dependency sources. The generate(…) parameters stay, matching sourceDirs:/sourceFiles:. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1d98d5f to
7c5b94e
Compare
|
Thanks for the review. I agree, adding multiple parameters can lead to bloat; originally I just tried to match the existing shape. I've now simplified it to one, but if you'd like to go the configuration way, I'm happy to take a look, though I'll need some input. Option 1 - CLIThe PR is cut down to only Option 2 - ConfigA module: ModuleB
sourceDirs: [Sources/ModuleB]
dependencies:
ModuleA:
sourceDirs: [Sources/ModuleA]
RIBs:
sourceDirs: [.build/checkouts/RIBs/ios/RIBs]
How did you imagine it?
|
|
@sidepelican gentle ping when you have a couple of minutes. Happy to work on this. |
|
@farkasseb This seems like a good opportunity to try Option 2 with a config file. For the config structure, I wonder if we could use a single list of paths for each module, containing both directories and individual files: {
module: "ModuleB",
sources: [
"Sources/ModuleB",
"Generated/AdditionalProtocol.swift",
],
destination: "Tests/ModuleBMocks.swift",
dependencies: {
ModuleA: [
"Sources/ModuleA",
"Shared/SomeProtocol.swift",
],
},
}Mockolo could determine whether each path is a directory or a file at runtime and collect all the sources.
I think of the config as an alternative to CLI arguments, so I’d like it to support the
One file per run is what I had in mind too. Each file would describe the context for a single mockolo invocation, so the number of invocations would stay the same.
The existing input options already have a precedence order: |
When mocks are generated per module, a protocol often refines a protocol from another module:
Running mockolo on
ModuleBalone, it cannot seeFoo, soNarrowFooMockmissesreset()and keeps thewhereclause on a non-generic class:What works today, and where it stops
-s, as suggested in Inheritance across modules #344. It resolves the parent, but it also mocks every annotated type inModuleA, soModuleBMocksduplicatesModuleAMocks.Interactabledoesn't allow, and redeclared members must be kept in sync by hand.--mockfiles(Fail to generate mock with protocol inheritance #146, Cont. on #146 Fail to generate mock with protocol inheritance #167). This works when the parent's module is mocked. For a third-party parent (Inheritance across modules #344, Fail to generate mock with protocol inheritance #146), the mock must be hand-written. It also relies on the parent mock feature Deprecations for the next major release #302 lists for removal.Change
Three options that mirror the source inputs, with the same precedence:
--dependency-sourcedirs--dependency-filelist--dependency-sourcefilesA #344-style setup can move its dependencies from
-sto--dependency-sourcedirsand stop mocking them. The #146/#167 case no longer needs parent mocks, so removing them as #302 proposes wouldn't leave per-module users with only-s. This PR leaves the parent mock feature unchanged; #302 notes Uber still uses it.Design choices:
--exclude-suffixesas the sources. Their protocols, annotated or not, are added to the protocol map used for inheritance resolution, never to the set of types to mock. No templates change, and without the new options the output is unchanged.--mockfiles(existing order), so a parent found in the dependencies is used instead of its parent mock.If you'd rather keep the surface small, I'm happy to cut this down to
--dependency-sourcedirsalone.Test
testPATWithSameTypeConstraintInDependency: the example above, withFoopassed as a dependency. It expectsNarrowFooMockwithreset(), nowhereclause and noFooMock. With the dependency input ignored, it fails on the keptwhereclause and the missingreset().🤖 Generated with Claude Code